I was helping a friend in finding all possible combinations of schedules for a given set of courses, and it varied wildly the number of schedules each course had, most had 2 or 3, but others had more than 15 schedules, and when selecting the larger ones, the number of possible combinations blew up, and it was taking a looong time to compute.
So then, for fun, I started to think that those were in each of the , which is roughly in total. So I asked myself, given a fixed number of schedules, How many courses should I distribute those so that it maximizes the number of possible combinations?
Just to be clear, changing schedules from one course to another does not make sense at all. This is just a purely algorithmic / mathematical question.
I have thought in the past about common cases of permutations and combinations, like for example, in the result that has more combinations is and , hence the more likely result.
So I thought “Hmm!, this looks familiar, I bet we can get the most combinations by distributing things evenly”, so my first guess was to distribute schedules in a way that the number of courses were the same as the average number of schedules in the courses, … roughly.
But that’s just a wild guess!, I want to know the real answer!
So naturally, I started testing my hypothesis. To make it simple, I started with . Let’s test different ways of distributing the items
>>> 5*5
25
>>> 4*4*2
32
>>> 3*3*3*1
27
>>> 2*2*2*2*2
32
>>> 3*3*4
36
So is the winner, groups of items, nice! my guess looks strong, both numbers are very close. But let’s test it with more items, let’s try items.
>>> 5*5*5*5
625
>>> 4*4*4*4*4
1024
>>> 3*3*3*3*3*3*2
1458
>>> 2*2*2*2*2*2*2*2*2*2
1024
Uh oh!, my guess is not doing well. The winner is now which is of , both numbers are now very different. And the average number of items, in both tests, are suspiciously close to .
But Hang on!, the groups of and give the same combinations in both cases, is there a connection here?.
Yes there is! If we look closely, and are essentially the same thing. In fact, we can always replace with , because they are equivalent in both calculating the combinations and preserving the number of items .
Ok, so if and , by logic are always the same regardless of the number of items, then does indeed seem to be the sweet spot. It’s interesting that I’ve never come across this fact.
Well, I wanted to test bigger numbers, but I got lazy, so I started to look for patterns, and I noticed that these calculations are equivalent to calculating numbers in other numerical systems with different bases.
For example, the number of combinations of distributed in groups of , results in of each, and that’s equivalent to the number of numbers that can be represented with in . This is because both scenarios involve making independent choices, each with options.
So in the of each, we get that the number of combinations is .
And in the case of in we get that the number of numbers that can be represented is .
Some of you might notice that is , instead of , but that’s because is ignored, so after we count it back, we get .
So these are the equivalences I found:
For example, How many items “units of information” do we need in to represent the number ?.
But first, What do I mean by “units of information” exactly?, I mean something like the amount of symbols used, … What???.
Yes, has 2 possibilities, or in each digit, so the “units of information” in is , and that’s the amount of symbols used to represent a number.
Ok, so to calculate the “units of information”, we need the number of bits needed to represent . Let’s hunt it!
>>> 2*2*2*2*2*2*2*2*2*2 # 10 bits
1024
>>> 2**10
1024
>>> 2**18
262144
>>> 2**19
524288 # almost there
>>> 2**20
1048576
Yeah I know, I could have just used the logarithm
>>> math.log(654987, 2)
19.321106747160712
So we got , and that means, that the “units of information” contained is .
Since seems to be the most efficient one, let’s find out what we can accomplish with the same but now in .
First, how many trigits (base-3 digits) can we get with ?.
, that means we can fully represent using less than , to be exact.
To use exactly 40 “units of information” we could use a number that is a frankenstein mix of and , specifically, and . But there’s no need to complicate things, let’s stick to .
Let’s see how many combinations we get with , or in other words, what’s the maximum number we can describe using ?, if we get more than what we get with , then is more efficient, and so is using sets of elements to maximize the cartesian product.
>>> 3**13
1594323
>>> 2**20
1048576
Yayy!, using we got more combinations, that means, we can represent more numbers, besides the fact that we have a tiny bit less “units of information” than , in fact, here’s the difference
>>> 3*13
39
>>> 2*20
40
So folks, if you want to maximize the combinations of a cartesian product, arrange your items in groups of .
Or conversely, if you want to minimize the number of combinations, stay away from groups of .
Weeell, it turns out is not really the most optimal number, but it’s close enough, it’s still the king among integers, and of many practical applications.
But the king of kings is in fact , the base of the natural logarithm.
And don’t ask me how a number system would even look like, nor how would you even name the … eits ?. You can read more about it here
BTW “Entropy” may be a related concept to this. I’ve seen people measuring entropy in bits, in this fascinating take of Death Note’s Light Yagami’s anonimity
Imagine an enemy is following you and you want to lose them.
Lucky for you, you live in a multiverse where people can jump through universes, and you have a unique ability that no one else can, you can jump to multiple universes at the same time, like creating clones of you, or more like forking yourself.
You may jump to a single universe, but that’s useless because the enemy can detect when and to which universe you jumped, and they can easily keep tracking you.
So you cannot really lose track of your enemy, what you can do is to overwhelm them!. If you jump to multiple universes at the same time, on each universe a different version of you will continue your journey, so even if your enemy tracks you, they will have to follow you on each universe, and each version of you can keep jumping deeper into the multiverse, you can see how this grows exponentially
So what’s the catch? Well, you can only jump 20 times. So how should you arrange those jumps in order to maximize the number of “versions of you” your enemy would have to keep track of?
Obviously, you should arrange them in jumps to ~3 universes. To be more precise, 6 jumps of 3 universes + 1 jump of 2 universes = 20 jumps, and that will give you 3*3*3*3*3*3*2 = 1458
“versions of you”